[id].vue 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <!-- Page de détails d'un sous-domaine -->
  2. <template>
  3. <div>
  4. <LayoutCommonSection>
  5. <UiLoadingPanel v-if="status == FETCHING_STATUS.PENDING" />
  6. <div v-else-if="subdomain !== null">
  7. <div>{{ $t('youRegisteredTheFollowingSubdomain') }} :</div>
  8. <div class="pa-8">
  9. <b>{{ subdomain.subdomain }}</b>
  10. <span class="text-on-neutral">.opentalent.fr</span>
  11. </div>
  12. <div>
  13. <div v-if="subdomain.active">
  14. <v-icon class="text-success icon small mr-2">
  15. fa-solid fa-check
  16. </v-icon>
  17. {{ $t('subdomainIsCurrentlyActive') }}
  18. </div>
  19. <div v-else>{{ $t('doYouWantToActivateThisSubdomain') }} ?</div>
  20. </div>
  21. <div class="mt-6 d-flex flex-row">
  22. <v-btn class="mr-12" @click="quit">
  23. {{ $t('back') }}
  24. </v-btn>
  25. <div v-if="!subdomain.active">
  26. <v-btn color="primary" @click="activateAndQuit">
  27. {{ $t('activate') }}
  28. </v-btn>
  29. </div>
  30. </div>
  31. </div>
  32. </LayoutCommonSection>
  33. </div>
  34. </template>
  35. <script setup lang="ts">
  36. import type { Ref } from 'vue'
  37. import Subdomain from '~/models/Organization/Subdomain'
  38. import { useEntityFetch } from '~/composables/data/useEntityFetch'
  39. import { useEntityManager } from '~/composables/data/useEntityManager'
  40. import { usePageStore } from '~/stores/page'
  41. import { TYPE_ALERT } from '~/types/enum/enums'
  42. import { useRefreshProfile } from '~/composables/data/useRefreshProfile'
  43. import { useRouteUtils } from '~/composables/utils/useRouteUtils'
  44. import { FETCHING_STATUS } from '~/types/enum/data'
  45. definePageMeta({
  46. name: 'activate_a_subdomain',
  47. })
  48. const { em } = useEntityManager()
  49. const { fetch } = useEntityFetch()
  50. const router = useRouter()
  51. const { refreshProfile } = useRefreshProfile()
  52. const { getIdFromRoute } = useRouteUtils()
  53. const id = getIdFromRoute()
  54. const { data: subdomain, status } = fetch(Subdomain, id)
  55. const activationPending: Ref<boolean> = ref(false)
  56. const pageStore = usePageStore()
  57. const activateAndQuit = async () => {
  58. activationPending.value = true
  59. pageStore.loading = true
  60. await em.patch(Subdomain, id, { active: true })
  61. await refreshProfile()
  62. usePageStore().addAlert(TYPE_ALERT.SUCCESS, [
  63. 'subdomain_activated_and_available_in_a_few_minutes',
  64. ])
  65. quit()
  66. }
  67. const quit = () => {
  68. router.push('/parameters/website')
  69. activationPending.value = false
  70. pageStore.loading = false
  71. }
  72. onUnmounted(() => {
  73. useRepo(Subdomain).flush()
  74. })
  75. </script>